<?php
/* @file helper.php
 * @author Liuexp
 * @description General API
 */
require_once("rb.php");
require_once("dwoo/dwooAutoload.php");


/* General Settings and Configuration */
R::setup("mysql:hosts=localhost;dbname=ACMOJ","liuexp","abcdefg");
define("DEBUG_ON","true");
define("INVALID_VOLUME","Invalid Volume!");
define("INVALID_PROBLEM","Invalid Problem!");
define("INVALID_SUBMIT","Invalid Submit!");
define("INVALID_LANG","Invalid Language!");
define("INVALID_VALIDATOR","Invalid Validator!");
define("ACCESS_DENIED","Access Denied!");
define("SUCC","Operation Done!");
define("FAIL","Operation Failed!");
define("PROBLEM_PER_PAGE","50");
define("VOLUME_PER_PAGE","50");
define("LANG_PER_PAGE","50");
define("VALIDATOR_PER_PAGE","50");
define("USER_PER_PAGE","50");
define("RECORD_PER_PAGE","50");

define("GROUP_NEW_VOLUME","5");
define("GROUP_EDIT_VOLUME","6");
define("GROUP_NEW_PROBLEM","7");
define("GROUP_EDIT_PROBLEM","8");
define("GROUP_NEW_LANG","9");
define("GROUP_EDIT_LANG","10");
define("GROUP_NEW_VALIDATOR","11");
define("GROUP_EDIT_VALIDATOR","12");
define("GROUP_SUBMIT_PROBLEM","13");
define("GROUP_DEL_VOLUME","14");
define("GROUP_DEL_LANG","15");
define("GROUP_DEL_VALIDATOR","16");
define("GROUP_DEL_PROBLEM","17");
define("GROUP_REJUDGE","18");
define("GROUP_SHOW_VOLUME","19");
define("GROUP_SHOW_PROBLEM","20");
define("GROUP_SHOW_LANG","21");
define("GROUP_SHOW_VALIDATOR","22");


//TODO:Functionality.
/* Test whether the given object is valid.
 * @param $bean
 * @return bool
 */
function isValidVolume($bean)
{
	if(empty($bean)||empty($bean->name))return false;
	return true;
}

/* Test whether the given object is valid.
 * @param $bean
 * @return bool
 */
function isValidProblem($bean)
{
	if(empty($bean)||empty($bean->name))return false;
	return true;
}

/* Test whether the given object is valid.
 * @param $bean
 * @return bool
 */
function isValidLanguage($bean)
{
	if(empty($bean)||empty($bean->name))return false;
	return true;
}


/* Test whether the given object is valid.
 * @param $bean
 * @return bool
 */
function isValidValidator($bean)
{
	if(empty($bean)||empty($bean->name))return false;
	return true;
}

/* Test whether the given object is valid.
 * @param $bean
 * @return bool
 */
function isValidSubmit($bean)
{
	if(empty($bean)||empty($bean->code))return false;
	return true;
}


/* Fetch the logged in user's id.
 * @return int $sharetronix_user_id
 */

function GetUserID()
{
	return 1;
}


/* Test whether the current user is
 * in a certain group, and thus have
 * the certain privilege.
 * @param string $g
 * @return bool
 */
function InGroup($g)
{
	return true;
}


/* Pop-up a message box.
 * @param string $msg
 * @return void
 */
function MsgBox($msg,$action="GOBACK")
{
	print $msg;
}

/* Write to logfile.
 * @param string $msg.
 */
function OJLog($msg)
{
	if(DEBUG_ON)print $msg;
	return ;
}
?>
